package com.gandong8.derby.core.interceptor;


import com.gandong8.derby.core.util.RequestUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Slf4j
public class IpInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
        if("127.0.0.1".equals(RequestUtil.getIp())) {
            return true;
        }
        RequestUtil.output("bye bye");
        return false;
    }

}
